/***********************************************************************
 * Module:  ControlTypeController.java
 * Author:  Administrator
 * Purpose: Defines the Class ControlTypeController
 ***********************************************************************/

package ishitong.rvims.control.controller;

import ishitong.rvims.control.service.ControlTypeService;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import ishitong.core.common.SQLSelectWhere;
import ishitong.rvims.domain.control.ControlType;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import ishitong.core.common.ActionController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/** @pdOid 2c598ea2-27b3-4833-b51f-c687619bfa7f */
@Controller
public class ControlTypeController extends ActionController {
   /** @pdOid 4d77c133-ffd6-49ad-8a6a-f78626c419af
       @pdRoleInfo migr=yes name=ControlTypeService assc=association1 */
   @Autowired
   public ControlTypeService controlTypeService;
   
   /** @param request 
    * @param response
    * @exception Exception
    * @pdOid c0010524-557e-47b8-9046-950ba9d03ffd */
   @RequestMapping(value = "/showControlTypeSearch.do")
   public ModelAndView handleShowControlTypeSearch(HttpServletRequest request, HttpServletResponse response) throws Exception {
      return new ModelAndView("control/ControlTypeSearch");
   }
   
   /** @param request 
    * @param response 
    * @param sQLSelectWhere
    * @exception Exception
    * @pdOid cbfe2259-d5fb-41b0-8f1a-5307fbc6f0e0 */
   @RequestMapping(value = "/ajaxControlTypeSearchList.do", method = RequestMethod.POST)
   public ModelAndView handleAjaxControlTypeSearchList(HttpServletRequest request, HttpServletResponse response, SQLSelectWhere sQLSelectWhere) throws Exception {
    	try {
    		Map<String, Object> model = new HashMap<String, Object>();
    		List<ControlType> listControlType = controlTypeService.findControlTypeList(sQLSelectWhere);
    		sQLSelectWhere.setRecordCount(controlTypeService.getControlTypeTotal(sQLSelectWhere));
    		model.put("listControlType", listControlType);
    		model.put("sQLSelectWhere", sQLSelectWhere);
    		return new ModelAndView("control/ControlTypeSearchList", model);
    	} catch (Exception e) {
    		e.printStackTrace();
    	}
      return null;
   }
   
   /** @param request 
    * @param response
    * @exception Exception
    * @pdOid 236e7f76-9e38-4bf5-9ac9-e2651cde1390 */
   @RequestMapping(value = "/showControlTypeAdd.do")
   public ModelAndView handleShowControlTypeAdd(HttpServletRequest request, HttpServletResponse response) throws Exception {
      return new ModelAndView("control/ControlTypeEdit");
   }
   
   /** Map<String, Object> model = new HashMap<String, Object>();
    * 
    * @param request 
    * @param response 
    * @param controlTypeId
    * @exception Exception
    * @pdOid 571f47a2-6512-4e19-85c5-bc6dd074898a */
   @RequestMapping(value = "/showControlTypeEdit.do", method = RequestMethod.POST)
   public ModelAndView handleShowControlTypeEdit(HttpServletRequest request, HttpServletResponse response, String controlTypeId) throws Exception {
     try {
   	Map<String, Object> model = new HashMap<String, Object>();
   	ControlType controlType = controlTypeService.getControlTypeById(controlTypeId);
   	model.put("controlType", controlType);
   	return new ModelAndView("control/ControlTypeEdit", model);
   } catch (Exception e) {
   	e.printStackTrace();
   }
   return null;
    }
   
   /** @param request 
    * @param response 
    * @param controlType
    * @exception Exception
    * @pdOid 63f84fde-e4b2-468a-b74a-be8d19d98aca */
   @RequestMapping(value = "/saveControlType.do", method = RequestMethod.POST)
   public ModelAndView handleSaveControlType(HttpServletRequest request, HttpServletResponse response, ControlType controlType) throws Exception {
     try {
   	controlTypeService.saveControlType(controlType);
   	return new ModelAndView("redirect:showControlTypeSearch.do");
   } catch (Exception e) {
   	e.printStackTrace();
   }
        return null;
     }
   
   /** @param request 
    * @param response 
    * @param controlTypeIds
    * @exception Exception
    * @pdOid 66d33711-d155-4403-88cd-8efffb6de7ac */
   @RequestMapping(value = "/ajaxDeleteControlTypeById.do", method = RequestMethod.POST)
   public String handleAjaxDeleteControlTypeByIds(HttpServletRequest request, HttpServletResponse response, String controlTypeIds) throws Exception {
     try {
      controlTypeService.deleteControlTypeByIds(controlTypeIds);
      return null;
   } catch (Exception e) {
   	e.printStackTrace();
   } 	   
     return null;
    }
   
   /** Map<String, Object> model = new HashMap<String, Object>();
    * 
    * @param request 
    * @param response 
    * @param controlTypeId
    * @exception Exception
    * @pdOid bb6214fc-7b7f-4f14-84c5-ba52cd119dfb */
   @RequestMapping(value = "/showControlTypeView.do", method = RequestMethod.POST)
   public ModelAndView handleShowControlTypeView(HttpServletRequest request, HttpServletResponse response, String controlTypeId) throws Exception {
     try {
   	Map<String, Object> model = new HashMap<String, Object>();
   	ControlType controlType = controlTypeService.getControlTypeById(controlTypeId);
   	model.put("controlType", controlType);
   	return new ModelAndView("control/ControlTypeView", model);
   } catch (Exception e) {
   	e.printStackTrace();
   }
     return null;
    }

}